package netty.task;

import io.netty.channel.Channel;
import redis.task.DeferredResultTask;

public class RemoteCmd<T> {
    private String cmdType;
    private String sessionId;
    private Channel channel;
    private T param;

    public static <T> RemoteCmd<T> fromTask(DeferredResultTask<T> task, Channel channel) {
        RemoteCmd<T> cmd = new RemoteCmd<>();
        cmd.sessionId = task.getSessionId();
        cmd.channel = channel;
        cmd.cmdType = task.getType();
        cmd.param = task.getData();
        return cmd;
    }

    public String getCmdType() {
        return cmdType;
    }

    public void setCmdType(String cmdType) {
        this.cmdType = cmdType;
    }

    public String getSessionId() {
        return sessionId;
    }

    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }

    public Channel getChannel() {
        return channel;
    }

    public void setChannel(Channel channel) {
        this.channel = channel;
    }

    public T getParam() {
        return param;
    }

    public void setParam(T param) {
        this.param = param;
    }
}
